<%@page import="com.glowdayz.glowmee.cmd.ProductCMD"%>
<%@page import="com.glowdayz.glowmee.dao.ProductDAO"%>
<%@page import="com.glowdayz.common.DBHandler"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%
	String second = request.getParameter("second");

	if (second.equals("default")) {
		
	%>
<?xml version="1.0" encoding="utf-8" ?>
<product>
	<item>
		<idProduct>default</idProduct>
		<productTitle>- 카테고리를 먼저 선택하세요 -</productTitle>
	</item>
</product>
	<%	
		return;
	}
	DBHandler.getInstance().connect();
	ProductDAO dao = ProductDAO.getInstance();
	String where = " AND p.idProduct IN (SELECT idProduct FROM secondcategorymapping WHERE idSecondCategory=" + second + ")";
	ArrayList<ProductCMD> cmd = dao.getProductList(1, -1, "p.productTitle", where);
	if (cmd != null) {
%>
<?xml version="1.0" encoding="utf-8" ?>
<product>
	<item>
		<idProduct>default</idProduct>
		<productTitle>- 제품을 선택하세요 -</productTitle>
	</item>
	<%
		for (int i=0; i<cmd.size(); i++) {
			ProductCMD temp = cmd.get(i);
	%>
	<item>
		<idProduct><%= temp.getIdProduct() %></idProduct>
		<productTitle><%= temp.getProductTitle() %></productTitle>
	</item>
	<%
		}
		DBHandler.getInstance().disconnect();
	%>
</product>
<%
	} else {
%>
<?xml version="1.0" encoding="utf-8" ?>
<product>
	<item>
		<idProduct>default</idProduct>
		<productTitle>- 해당 2차 카테고리 데이터없음 -</productTitle>
	</item>
</product>
<%}%>